const express = require("express")

const Router = express.Router()
const configSql = require("../../db/db");

// 美食推荐
Router.get("/get_foods_recommend", (req, res) => {
    let sql = `select * from foods_list limit 0,8`
    configSql(sql).then(result => {
        res.send({
            code: 0,
            msg: "获取成功",
            data: result,
        })
    })
})

Router.get('/query_foods', (req, res) => {
    let {
        keyword,
        city
    } = req.query
    if ( !city) {
        res.send({
            code: 500,
            msg: '参数缺失'

        })
    }
    let sql = `select * from foods_list where city like'%${city}%' limit 0,8`
    configSql(sql).then(result => {
        res.send({
            code: 0,
            msg: "获取成功",
            data: result,
        })
    })
})






// 导出路由
module.exports = Router;